/* 轮播原脚本不动 */
var index = 1, max = 3;
var firstImgDom = document.querySelector('.banner img');
firstImgDom.style.display = 'block';
var bottonDomLeft = document.querySelector('#leftBtn');
var bottonDomRight = document.querySelector('#rightBtn');
bottonDomLeft.onclick = function () {
    var nextIndex = ((index + 1) % max) + 1;
    var nextImgDom = document.querySelector(".banner img:nth-child(" + nextIndex + ")");
    nextImgDom.style.display = 'block';
    var nowImgDom = document.querySelector(".banner img:nth-child(" + index + ")");
    nowImgDom.style.display = 'none';
    index = nextIndex;
}
bottonDomRight.onclick = function () {
    var nextIndex = (index % max) + 1;
    var nextImgDom = document.querySelector(".banner img:nth-child(" + nextIndex + ")");
    nextImgDom.style.display = 'block';
    var nowImgDom = document.querySelector(".banner img:nth-child(" + index + ")");
    nowImgDom.style.display = 'none';
    index = nextIndex;
}
// 登录状态检查
function updateUserEntry() {
    const isLogin = localStorage.getItem('isLogin'); // 你注册/登录成功后 set 这个
    const entry = document.getElementById('userEntry');
    if (isLogin === '1') {
        entry.textContent = '我的';
        entry.href = 'user.html';   // 跳用户中心
    } else {
        entry.textContent = '登录';
        entry.href = 'log.html';    // 跳登录页
    }
}
// 首次加载 + 每次加车都检查（保险）
updateUserEntry();
window.addEventListener('storage', updateUserEntry); // 跨页同步